#
# Copyright (C) 2006-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
#include $(TOPDIR)/package/comlanos/common.mk

PKG_NAME:=goahead_new

PKG_REV:=0001
PKG_VERSION:=r$(PKG_REV)
PKG_RELEASE:=6

PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

define Package/goahead_new
  CATEGORY:=cjdgy
  DEPENDS:=+libubox +libuci +libjson-c  +zlib +libcurl +libiw +libpthread
  TITLE:=aplication goahead_new
endef

define Package/goahead_new/description
 goahead
endef

ZLIB_H = -I$(STAGING_DIR)/usr/include
TARGET_CFLAGS += -ffunction-sections -fdata-sections $(ZLIB_H)
TARGET_LDFLAGS += -Wl,--gc-sections
UMSW	= -DUSER_MANAGEMENT_SUPPORT
TARGET_CFLAGS	+= -DWEBS -DUEMF -DOS="LINUX" -DLINUX -DLANG_EN -DHAVE_WISP -DLANG_EN -DUPGRADE_COMPATIBLE $(UMSW)

define Build/Prepare
	cp -rf $(CJDGY_DIR)/source/$(PKG_NAME)/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS)" \
		LIBS="$(TARGET_LDFLAGS) -lubox -luci -lm -ljson-c -lz -lcurl -liw -lpthread" \
		all
	#$(MAKE) -C $(PKG_BUILD_DIR)/cgi-src/ \
	#	$(TARGET_CONFIGURE_OPTS) \
	#	CFLAGS="$(TARGET_CFLAGS)" \
	#	all
endef	

define Package/goahead_new/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/goahead_new $(1)/usr/bin/
	
	
	mkdir -p $(1)/etc/goahead
	$(CP)  -fr ./files/wwwdemo $(1)/etc/goahead/
	
	mkdir -p $(1)/etc/goahead
	$(CP)  -fr ./files/www $(1)/etc/goahead/
	
	#mkdir -p $(1)/etc_ro/web/cgi-bin/
	#$(CP) $(PKG_BUILD_DIR)/cgi-src/*.cgi $(1)/etc_ro/web/cgi-bin/
endef

$(eval $(call BuildPackage,goahead_new))
